Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Windows.Forms

Public Class FrmCrPXUAT_TC_MH_KM

    Private Tungay, Denngay As String
    Private customerReport As ReportDocument

    Private Sub FrmCrPXUAT_TC_MH_KM_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'frmLoading.Show()
        Dim sqlQuery As String = "SELECT t1.ma_hanghoa,t3.ten_bietduoc,t3.donvi_banchan,SUM(t1.soluongle) as soluong,sum(t1.soluongle*t1.giavon)/sum(t1.soluongle) as dongiavon,sum(t1.soluongle*t1.dongia)/sum(t1.soluongle) as dongiaban,sum(round(t1.soluongle*ROUND(t1.giavon,2),0)) as thanhtienvon,sum(round(t1.soluongle*round(t1.dongia,2),0)) as thanhtienban FROM (tbl_xuat_chitiet_hanghoa as t1 INNER JOIN  tbl_xuat_hanghoa as t2 ON t1.ma_chungtu=t2.ma_chungtu )LEFT JOIN tbl_hanghoa as t3 ON t1.ma_hanghoa=t3.ma_hanghoa  WHERE  t2.ngay_chungtu BETWEEN '" & Format(CDate(Tungay), "yyyy-MM-dd") & "' AND '" & Format(CDate(Denngay), "yyyy-MM-dd") & "' AND t1.loaixuat=3  GROUP BY t1.ma_hanghoa "
        Dim reportPath = Application.StartupPath & "\" & "crPXUAT_TC_MH_KM.rpt"
        customerReport = New ReportDocument()
        customerReport.Load(reportPath)
        customerReport.SetDataSource(moduleReportConfig.GetDataTable(sqlQuery))
        customerReport.SetParameterValue("TTungay", Tungay)
        customerReport.SetParameterValue("TDenngay", Denngay)
        Me.CrNXTTongHopview.ReportSource = customerReport
        'frmLoading.Close()
        'frmLoading.Dispose()
    End Sub

    
    Public Sub setTungay(ByVal s As String)
        Tungay = s
    End Sub

    Public Sub setDenngay(ByVal s As String)
        Denngay = s
    End Sub

End Class
